/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package BLL;

import BE.Song;
import DAL.SearchDBManager;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Zalan
 */
public class SearchManager {
    
    public String artistSelection;
    public String genreSelection;
    public String searchValue;
    private SearchDBManager sdb;
    
    public SearchManager()
    {
        try {
            sdb = SearchDBManager.getInstance();
        } catch (IOException ex) {
            System.out.println("Error" +ex);
        }
    }
    
    public void getArtistSelection(Object obj)
    {
        this.artistSelection = obj.toString();
    }

    public void getGenreSelection(Object obj) 
    {
        this.genreSelection = obj.toString();
    }

    public void searchValue(String text) 
    {
        this.searchValue = text;
    }
    
    public ArrayList<Song> searchAction()
    {
        ArrayList<Song> sngList = new ArrayList<>();
        try 
        {
            sngList = sdb.activateSearch(artistSelection, genreSelection, searchValue);
        } catch (SQLException ex) {
            Logger.getLogger(SearchManager.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return sngList;
    }
}
